home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / blit / bit_on.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-24  |  1.1 KB  |  36 lines

  1. /*                        Copyright (c) 1988 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: bit_on.c,v 4.2 88/07/20 14:16:57 sau Exp $
  9.     $Source: /tmp/mgrsrc/src/blit/RCS/bit_on.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /tmp/mgrsrc/src/blit/RCS/bit_on.c,v $$Revision: 4.2 $";
  12.  
  13. #include "bitmap.h"
  14.  
  15. /*    Return "true" (one) if the bit at the given x,y position
  16.     is set in the given bitmap.
  17.     Return "false" (zero) if that bit is not set or if the x,y is outside
  18.     the bitmap.
  19. */
  20. #define    BITSPERDATA    (sizeof(int) * 8)
  21.  
  22. int
  23. bit_on( bp, x, y )
  24. register BITMAP    *bp;
  25. int        x, y;
  26. {
  27.     register int    mask = 1 << (BITSPERDATA - ( x%BITSPERDATA + 1));
  28.     register int    *ip;
  29.  
  30.     if( x >= BIT_WIDE(bp)  ||  y >= BIT_HIGH(bp) )
  31.         return  0;
  32.     ip = BIT_DATA( bp ) +
  33.         (x/BITSPERDATA + y*BIT_Size( BIT_WIDE(bp), 1, 1 )/sizeof(int));
  34.     return  (*ip & mask) != 0;
  35. }
  36.